 var BASE = "https://www.studyjava.cn";
// var BASE = 'http://127.0.0.1:8585/blog';
var BASE_URL = BASE + '/api';


//首页 blog列表
var blog_index = '/indexs';
var blog_content = '/indexs/getBlog';

//娱乐
var yule_index = '/fuli';
var yule_content = '/fuli/getFuli';

//我的
var user_session_key = '/login/getSessionKey'
var user_register = '/login/register'

function obj2uri(obj) {
    return Object.keys(obj).map(function (k) {
        return encodeURIComponent(k) + '=' + encodeURIComponent(obj[k]);
    }).join('&');
}

module.exports = {
    
    getBaseURL: function (obj) {
        return BASE;
    },
    // 获取列表数据
    getBlogs: function (obj) {
        // console.log(BASE_URL + blog_index + '?' + obj2uri(obj))
        return BASE_URL + blog_index + '?' + obj2uri(obj);
    },
    // 获取博客详情页
    getBlog: function (obj) {
        // console.log(BASE_URL + blog_content + '?' + obj2uri(obj))
        return BASE_URL + blog_content + '?' + obj2uri(obj);
    },
    //获取主播页面
    getFulis: function (obj) {
        console.log(BASE_URL + yule_index + '?' + obj2uri(obj))
        return BASE_URL + yule_index + '?' + obj2uri(obj);
    },

    getFuli: function (obj) {
        console.log(BASE_URL + yule_content + '?' + obj2uri(obj))
        return BASE_URL + yule_content + '?' + obj2uri(obj);
    },
    //获取sessionKey
    getSessionKey(){
        console.log(BASE_URL + user_session_key)
        return BASE_URL + user_session_key;
    },
    //通过微信小程序注册用户
    register(){
        console.log(BASE_URL + user_register )
        return BASE_URL + user_register;
    }
};
